/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  							 script_army_action.h

	$Header: /heroes4/script_army_action.h $

	$NoKeywords: $

 ************************************************************************/


#if !defined(AFX_SCRIPT_ARMY_ACTION_H__0B942616_431C_40D0_983C_E837756B47F5__INCLUDED_)
#define AFX_SCRIPT_ARMY_ACTION_H__0B942616_431C_40D0_983C_E837756B47F5__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "script_targeted_action.h"
#include "streambuf_operators.h"
#include "script_targeting.h"
#include "script_target_type.h"
#include "creature_array.h"

class t_script_army_action
	:	public t_script_targeted_action< t_script_army_target >
{
public:
	virtual void	execute(t_script_context_hero const& context) const;
	virtual void	execute(t_script_context_town const& context) const;
	virtual void	execute(t_script_context_object const& context) const;
	virtual void	execute(t_script_context_army const& context) const;
	virtual void	execute(t_script_context_global const& context) const;

protected:
	virtual void	do_action(t_creature_array* array) const = 0;
};

inline void t_script_army_action::execute(t_script_context_hero const& context) const
{
	t_creature_array* target_army = select_army_by_target(get_target(), NULL, context.army, context.opposing_army );

	do_action(target_army);
}

inline void t_script_army_action::execute(t_script_context_town const& context) const
{
	t_creature_array* target_army = select_army_by_target(get_target(), context.garrison, NULL, context.opposing_army );

	do_action(target_army);
}

inline void t_script_army_action::execute(t_script_context_object const& context) const
{
	assert(false);
}

inline void t_script_army_action::execute(t_script_context_army const& context) const
{
	t_creature_array* target_army = select_army_by_target(get_target(), NULL, context.army, context.opposing_army );

	do_action(target_army);
}

inline void t_script_army_action::execute(t_script_context_global const& context) const
{
	assert(false);
}

#endif 
